<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title></title> 
    <style type="text/css">
   	*{
   		margin: 0;padding: 0;
   	}

   	.line{
   		width: 100%;
   		height: 1px;
   		top: 300px;
   		position: absolute;
   		background: black;
   	}

   	#dargen{
   		width: 100px;height: 100px;
   		position: absolute;
   		top: 230px;
   		background: green;
   		left: 30px;
   	}
   	.xrz{
   		left: 80%;
   		width: 20px;
   		background: black;
   		position: absolute;
   		top: 240px; 
   	}

    </style>
    <script type="text/javascript" src='jquery-1.9.1.min.js'></script>
</head>
<body>
<div class='line'></div>
<div id='dargen'></div>

<script type="text/javascript">
var t = true;
	$(document).on({
		'click':function(){
			if(!t)return;
			t = false;
			$('#dargen').stop().animate({
				'top':30
			},500,function(){
				$('#dargen').stop().animate({
					'top':230
				},500,function(){
					t = true;
				});
			})
		}
	});


	var s = $('<div class="xrz"></div>');
	s.appendTo('body');
	s.css('height','90px');
	$(s).animate({
		'left':'0%'
	},3000,'linear');

	setInterval(leoDolt,30,dargen,s[0]);

function leoDolt(long,zhangai){
	var div2r = long.offsetLeft + long.offsetWidth;
	var div2b = long.offsetTop  + long.offsetHeight;
	var div2t = long.offsetTop;
	var div2l = long.offsetLeft;

	var div1l = zhangai.offsetLeft;
	var div1t = zhangai.offsetTop;
	var div1b = div1t + zhangai.offsetHeight;
	var div1r = zhangai.offsetWidth + div1l;


	if(div2r > div1l && div2b > div1t && div2t < div1b && div2l < div1r){
		alert('gameover');
		//div2.style.background = 'pink';
		//alert(1);
	}
	
}
/*
	div2.onmousedown = function(e){
		var ev = e || event;
		var posX = ev.clientX - this.offsetLeft;
		var posY = ev.clientY - this.offsetTop;

		document.onmousemove = function(e){
			var ev = e || event;
			var div2r = div2.offsetLeft + div2.offsetWidth;
			var div2b = div2.offsetTop  + div2.offsetHeight;
			var div2t = div2.offsetTop;
			var div2l = div2.offsetLeft;

			var div1l = div1.offsetLeft;
			var div1t = div1.offsetTop;
			var div1b = div1t + div1.offsetHeight;
			var div1r = div1.offsetWidth + div1l;


			if(div2r > div1l && div2b > div1t && div2t < div1b && div2l < div1r){
				div2.style.background = 'pink';
				//alert(1);
			}
			else{
				div2.style.background = 'green';
			}
			div2.style.left = ev.clientX - posX + 'px';
			div2.style.top  = ev.clientY - posY + 'px';
		}

		document.onmouseup = function(){
			document.onmouseup = document.onmousemove = null;
		}
		return false;
	};

*/
</script>
</body>
</html>